import request from '@/utils/request'

import Qs from 'qs'

export function loginByUsername(username, password) {
  return request.get('/api/oauth/token', {
    params: {
      'username': username,
      'password': password,
      'grant_type': 'password',
      'scope': 'select',
      'client_id': 'client_2',
      'client_secret': '123456'
    }
  })
}

export function logout() {
  return request({
    url: '/login/logout',
    method: 'post'
  })
}

export function getUserInfo(username, password) {
  return request({
    url: '/api/user/userinfo',
    method: 'post',
    transformRequest: [function(data) {
      // 对 data 进行任意转换处理
      return Qs.stringify(data)
    }],
    data: {
      userName: username,
      password: password
    }
  })
}

